<template>
	<view class="patient-container">
		<view class="header">
			<text class="title">患者主页</text>
		</view>
		
		<view class="content">
			<view class="welcome-card">
				<text class="welcome-text">欢迎回来</text>
				<text class="user-name">{{userName}}</text>
			</view>
			
			<view class="function-list">
				<view class="function-item" @tap="navigateTo('/pages/appointment/index')">
					<view class="function-icon">
						<text class="iconfont">📅</text>
					</view>
					<text class="function-name">预约挂号</text>
				</view>
				
				<view class="function-item" @tap="navigateTo('/pages/medical-record/index')">
					<view class="function-icon">
						<text class="iconfont">📋</text>
					</view>
					<text class="function-name">病历查询</text>
				</view>
				
				<view class="function-item" @tap="navigateTo('/pages/consultation/index')">
					<view class="function-icon">
						<text class="iconfont">💬</text>
					</view>
					<text class="function-name">在线问诊</text>
				</view>
				
				<view class="function-item" @tap="navigateTo('/pages/personal/index')">
					<view class="function-icon">
						<text class="iconfont">👤</text>
					</view>
					<text class="function-name">个人中心</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName: '患者',
				userInfo: null
			}
		},
		onLoad() {
			// 获取存储的用户信息
			try {
				const userInfoStr = uni.getStorageSync('userInfo');
				if (userInfoStr) {
					this.userInfo = JSON.parse(userInfoStr);
					this.userName = this.userInfo.name || '患者';
				}
			} catch (e) {
				console.error('获取用户信息失败', e);
			}
		},
		methods: {
			// 页面导航
			navigateTo(url) {
				uni.navigateTo({
					url: url
				});
			}
		}
	}
</script>

<style>
	.patient-container {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 40rpx;
	}
	
	.header {
		background-color: #8B4513;
		padding: 60rpx 40rpx 40rpx;
		color: #ffffff;
	}
	
	.title {
		font-size: 36rpx;
		font-weight: bold;
	}
	
	.content {
		padding: 30rpx;
	}
	
	.welcome-card {
		background-color: #ffffff;
		border-radius: 16rpx;
		padding: 40rpx;
		margin-bottom: 30rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
	}
	
	.welcome-text {
		font-size: 28rpx;
		color: #666666;
		margin-bottom: 10rpx;
	}
	
	.user-name {
		font-size: 40rpx;
		font-weight: bold;
		color: #333333;
	}
	
	.function-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}
	
	.function-item {
		width: 48%;
		background-color: #ffffff;
		border-radius: 16rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		display: flex;
		align-items: center;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
	}
	
	.function-icon {
		width: 80rpx;
		height: 80rpx;
		background-color: #f0e6d2;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 20rpx;
	}
	
	.iconfont {
		font-size: 40rpx;
		color: #8B4513;
	}
	
	.function-name {
		font-size: 28rpx;
		color: #333333;
		font-weight: 500;
	}
</style>